//
// Author: Vladimir Migashko <migashko@gmail.com>, (C) 2011
//
// Copyright: See COPYING file that comes with this distribution
//

#ifndef HITLIST_USER_HITS_FUNC_HPP
#define HITLIST_USER_HITS_FUNC_HPP

#include "hit_item.hpp"
#include <utility>

/** @brief Предикат сравнения пары (user_id_t, span_t) по user_id_t */
struct f_hit_equal
{
  bool operator()( const std::pair< user_id_t, span_t >& p1, 
                 const std::pair< user_id_t, span_t >& p2 ) const
  {
    return p1.first == p2.first;
  }
};


struct f_hit_equal_second
{
  user_id_t second_id;
  f_hit_equal_second(user_id_t second_id):second_id(second_id){}
  bool operator()( const std::pair< user_id_t, span_t >& p) const
  {
    return p.first == second_id;
  }
};


/** @brief Компоратор меншьше сравнения пары (user_id_t, span_t) по span_t */
struct f_hit_less
{
  bool operator()( const std::pair< user_id_t, span_t >& p1, 
                 const std::pair< user_id_t, span_t >& p2 ) const
  {
    return p1.second < p2.second;
  }
};

/** @brief Компоратор меншьше сравнения hit_item по time_stamp */
struct f_hit_item_less
{
  bool operator()( const hit_item& p1, 
                 const hit_item& p2 ) const
  {
    return p1.time_stamp < p2.time_stamp;
  }
};

/** @brief Предикат сравнения hit_item.id с заданым id*/
struct f_hit_item_equal
{
  user_id_t id;
  f_hit_item_equal(user_id_t id): id(id) {}
  bool operator()( const hit_item& p) const
  {
    return p.second_id == id;
  }
};

/** @brief Функтор сброса хитов*/
struct f_hit_item_reset_hits
{
  void operator()(hit_item& h)
  {
    h.hits = 0;
  }
};


#endif

